//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.hustcad.plm.pdm.mda.controller;

import com.alibaba.fastjson.JSONObject;
import com.hustcad.plm.pdm.mda.dto.AttributeSyncTreeDTO;
import com.hustcad.plm.pdm.mda.dto.CadModelLinkPartAttrSyncDTO;
import com.hustcad.plm.pdm.mda.dto.PartCadNameLinkDTO;
import com.hustcad.plm.pdm.mda.service.TyplmPartAttributeSyncCADService;
import com.hustcad.plm.pdm.mda.vo.AttributeSyncTreeVO;
import com.hustcad.plm.pdm.mda.vo.CadModelLinkPartAttrSyncVO;
import com.ty.basic.entity.view.ViewDefDO;
import com.ty.basic.response.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import javax.annotation.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(
        tags = {"TS、PLM、三维软件属性同步"}
)
@RestController
@RequestMapping({"/rest/v1/attrsync"})
public class TyplmPartAttributeSyncCADController {
    private static final Logger log = LoggerFactory.getLogger(TyplmPartAttributeSyncCADController.class);
    @Resource
    private TyplmPartAttributeSyncCADService typlmPartAttributeSyncCADService;

    public TyplmPartAttributeSyncCADController() {
    }

    @PostMapping({"/getLinkedPartListByCADModel"})
    @ApiOperation(
            value = "根据CAD模型获取关联的零部件列表,初始化图纸零部件关系列表",
            notes = "根据CAD模型获取关联的零部件列表,初始化图纸零部件关系列表",
            produces = "application/json; charset=utf-8"
    )
    public ResponseResult<List<AttributeSyncTreeVO>> getLinkedPartListByCADModel(@RequestBody AttributeSyncTreeDTO attributeSyncTreeDTO) {
        return ResponseResult.success(this.typlmPartAttributeSyncCADService.getLinkedPartListByCADModel(attributeSyncTreeDTO));
    }

    @PostMapping({"/checkCadPartLnkExist"})
    @ApiOperation(
            value = "查询part是否与其他图纸建立关系",
            notes = "查询part是否与其他图纸建立关系",
            produces = "application/json; charset=utf-8"
    )
    public ResponseResult checkCadPartLnkExist(@RequestBody List<PartCadNameLinkDTO> list) {
        this.typlmPartAttributeSyncCADService.checkCadPartLnkExist(list);
        return ResponseResult.success();
    }

    @PostMapping({"/syncPartAttribute"})
    @ApiOperation(
            value = "将零件属性同步到图纸属性",
            notes = "将零件属性同步到图纸属性",
            produces = "application/json; charset=utf-8"
    )
    public ResponseResult<List<CadModelLinkPartAttrSyncVO>> syncPartAttribuite(@RequestBody List<CadModelLinkPartAttrSyncDTO> list) {
        List<CadModelLinkPartAttrSyncVO> cadModelLinkPartAttrSyncVOS = this.typlmPartAttributeSyncCADService.syncPartAttribuite(list);
        return ResponseResult.success(cadModelLinkPartAttrSyncVOS);
    }

    @GetMapping({"/queryDesignView"})
    @ApiOperation(
            value = "查询设计视图",
            notes = "查询设计视图",
            produces = "application/json; charset=utf-8"
    )
    public ResponseResult<ViewDefDO> queryDesignView() {
        return ResponseResult.success(this.typlmPartAttributeSyncCADService.queryDesignView());
    }
}
